using FGUFW.Core.System;
using FGUFW.Play;
using System.Collections;
using UnityEngine;
using FGUFW.Core;
using UnityEngine.ResourceManagement.AsyncOperations;

namespace FGUFW.Play.StepGrid
{
    public class HomeModule : IPlayModule, IHomeInput
    {
        GameObject _view;
        public void Init()
        {
            if(_view==null)
            {
                StepGridPlayManager.I.UISystem.Open("Home",loadUICompleted);
            }
        }

        void loadUICompleted(GameObject view)
        {
            _view = view;
            _view.GetComponent<HomeView>().HomeInput=this;
            Show();
        }

        public void OnClickDefaultMode()
        {
            Hide();
            StepGridPlayManager.I.Module<DefaultModeModule>().Show();
        }

        public void Hide()
        {
            _view.transform.localPosition = UISystem.Config.HIDE_POS;
        }

        public void Show()
        {
            _view.transform.localPosition = UISystem.Config.SHOW_POS;
            StepGridPlayManager.I.Module<DefaultModeModule>().Init();
        }

        public void Release()
        {
            _view.SetActive(false);
            _view.GetComponent<HomeView>().HomeInput=null;
            _view=null;
        }
    }
}